#include<bits/stdc++.h>
using namespace std;

vector<int> explorationSupply(vector<int>& station, vector<int>& pos)
{
    vector<int> ans;
    
    for(auto i:pos)
    {
		int mn = 0x3f3f3f3f, idx;
        for(int j = 0;j < station.size();j++)
        {
        	if(abs(station[j]-i) < mn)
        	{
        		mn = abs(station[j]-i);
        		idx = j;
			}
		}
		ans.push_back(idx);
    }
    return ans;
}

int main()
{
	int n, m, x;
	vector<int> station, pos;
	cin>>n;
	for(int j = 1;j <= n;j++)
	{
		cin>>x;
		station.push_back(x);
	}
	
	cin>>m;
	for(int j = 1;j <= m;j++)
	{
		cin>>x;
		pos.push_back(x);
	}
	
	vector<int> ans = explorationSupply(station, pos);
	for(auto j:ans)
		cout<<j<<" ";
	
	return 0;
}

